namespace Web.Control.WWW.Wiki
{
    using System;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;
    using Lx.Web.Common.UI;
    using Lx.Web.Common.ControlsUI;
    using System.Collections;
    using System.Collections.Generic;
    using System.Xml;
    using System.IO;
    using System.Text;

    using BLF;
    using BLF.WWW_WWW.Wiki;
    using Model.WWW_WWW.Wiki;

    public class Upload : BaseControl
    {
        protected string MAXFILESIZE = "";

        protected void Page_Load(object sender, EventArgs e)
        {
            Page.Title = Exchanger.ResourceExchanger.GetResource("UploadTitle") + " - " + Settings.WikiTitle;

            MAXFILESIZE = Tools.BytesToString(Settings.MaxFileSize * 1024);

            if (SessionFacade.LoginKey != null)
            {
                // Registered User
                if (!SessionFacade.Admin)
                {
                    // Normal User
                    if (!Settings.UsersCanViewFiles) Response.Redirect("AccessDenied.htm");
                }
                // Else: User is an Admin, therefore can do any operation
            }
            else
            {
                // Anonymous User
                if (!Settings.PublicAccess) Response.Redirect("/user/Login.htm?ReturnUrl=Upload.htm");
                else
                {
                    // Public Access
                    if (!Settings.UsersCanViewFiles) Response.Redirect("/user/Login.htm?ReturnUrl=Upload.htm");
                    else
                    {
                        if (!Settings.FileManagementInPublicAccessAllowed) Response.Redirect("/user/Login.htm?ReturnUrl=Upload.htm");
                    }
                }
            }

        }       
       
    }
}
